﻿using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using Abp.Runtime.Validation;
using apbmvc.model;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace apbmvc.companys.Dto
{
    [AutoMapFrom(typeof(companies))]
    public class companyDto : EntityDto<int>, IShouldNormalize //IShouldNormalize 设置缺省值
        ,ICustomValidate
    
    {
        [Required]
        [StringLength(20)]
        /// <summary>
        /// Desc:公司名称 
        public  string comname { get; set; }

        [Required]
        [StringLength(100)]
        /// <summary>
        /// Desc:公司简称
        /// </summary>
        public  string comnameshort { get; set; }


        /// <summary>
        /// Desc:公司性质
        /// </summary>
        public  int natureid { get; set; }


        public void Normalize() //设置缺省值(默认值)
        {
            if (natureid==0)
            {
                natureid = 5;
            }
        }


        public void AddValidationErrors(CustomValidationContext results)
        {
            if (natureid>100)
            {
                     results.Results.Add(new ValidationResult("公司性质限制最大100!"));
            }
        }
    }

}
